package com.bobo.demo.Thread.sync;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

//测试线程池
public class TestPool {

    public static void main(String[] args) {
        //1、创建服务，创建线程池
        ExecutorService executorService = Executors.newFixedThreadPool(10);

        //执行
        executorService.execute(new MyThread());
        executorService.execute(new MyThread());
        executorService.execute(new MyThread());
        executorService.execute(new MyThread());

        //2 关闭链接
        executorService.shutdown();
    }

}

class MyThread implements Runnable {

    @Override
    public synchronized void run() {
        System.out.println(Thread.currentThread().getName()+"执行中");
    }
}